import axios from 'axios'
import utils from '../common/utils'
import es6promise from 'es6-promise'
es6promise.polyfill();
import userModel from './userModel'
import loginModel from './loginModel'
import projectModel from './projectModel'
import dtuModel from './dtuModel'
import hotPic from './hotPic'
import monitorAlarmModel from './monitorAlarmModel'
import riskTabModel from './riskTabModel'
import reportModel from './reportModel'
import sensorModel from './sensorModel'
import profileModel from "./profileModel";
import bimViewDataModel from "./bimViewDataModel"


axios.default.timout = 5000;
axios.default.baseURL = 'http://localhonst:8080';

axios.interceptors.request.use(
    config => {
        const token = sessionStorage.getItem('token');
        config.headers = {
            'Content-Type': 'application/json',
            'token':token,
        }
        return config;
    },
    err => {
        return Promise.reject(err);
    });

axios.interceptors.response.use(
    response => {
    	//TODO请求错误后跳转
        return response;
    }, error => {
        return Promise.reject(error);
    });

export default function(Vue,options = {}) {

	Vue.prototype.axios = axios;

	Vue.prototype.userModel = new userModel(options);

    Vue.prototype.loginModel = new loginModel(options);

    Vue.prototype.projectModel = new projectModel(options);

    Vue.prototype.profileModel = new profileModel(options);

    Vue.prototype.dtuModel = new dtuModel(options);

    Vue.prototype.riskTabModel = new riskTabModel(options);

    Vue.prototype.monitorAlarmModel = new monitorAlarmModel(options);

    Vue.prototype.sensorModel = new sensorModel(options);

    Vue.prototype.bimViewDataModel = new bimViewDataModel(options);
    
    Vue.prototype.reportModel = new reportModel(options);

    Vue.prototype.hotPic = new hotPic(options);
}
